using System.Collections.Generic;
using System.Xml.XPath;

namespace Weather.com.Client.WeatherConditions.Common
{
    internal class WeatherInfoBaseFactory
    {
        internal WeatherInfoBase Create(XPathNavigator navigator, WeatherInfoBase weatherInfo)
        {
            weatherInfo.Units = new UnitInfoFactory().Create(navigator);
            weatherInfo.Location = new LocationInfoFactory().Create(navigator);
            weatherInfo.PromotionalLinks = new List<PromoLink>();

            XPathNodeIterator promoLinksIterator = navigator.Select("/weather/lnks/link");
            while (promoLinksIterator.MoveNext())
            {
                PromoLink promoLink = new PromoLinkFactory().Create(promoLinksIterator);
                weatherInfo.PromotionalLinks.Add(promoLink);
            }
            return weatherInfo;
        }
    }
}